<template>
  <transition name="el-zoom-in-top">
    <el-form :model="searchParam" inline style="width: 100%;background: #F4F8F9;margin-bottom: 24px;">
      <el-row>
        <el-col :span="8">
          <el-form-item label="客户名称:" prop="customerName">
            <el-input v-model="searchParam.customerName" class="input-with-select"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户经理:" prop="managerId">
            <ft-user-query class="input-with-select" :clearable="true" v-model="searchParam.managerId" :editable="true"
                           style="width: 100%"></ft-user-query>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="所属部门:" prop="deptId">
            <ft-dept-select v-model="searchParam.deptId" :clearable="true" :org="orgId" class="input-with-select"
                            style="width: 100%"></ft-dept-select>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="证件号码:" prop="identityNo">
            <el-input v-model="searchParam.identityNo" class="input-with-select"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="客户类型:" prop="identityNo">
            <ft-enum-checkbox-query v-model="searchParam.customerType" service-name='lss-customer' :multiple="true"
                                    type-name='customerType' class="input-with-select"></ft-enum-checkbox-query>
          </el-form-item>
        </el-col>
      </el-row>
      <hr style="background-color: #EDEDED;border: none;height: 1px;margin: 0px"/>
      <el-row style="padding:16px 0px">
        <el-col align="right">
          <el-button @click="reset" size="mini" style="margin-right: 24px;">重置</el-button>
          <el-button @click="query" type="primary" size="mini" style="margin-right: 24px;">搜索</el-button>
        </el-col>
      </el-row>
    </el-form>
  </transition>
</template>

<script>
  export default {
    name: "CustomerQueryForm",
    components: {},
    mounted() {
      this.$http.get('/joys-rest/joys-master-data/orgs/default').then(resp => {
        this.orgId = resp.body.orgID
      }, resp => {
        this.$message.error('系统繁忙')
      })
    },
    data() {
      return {
        searchParam: {customerType: [], deptId: null},
        orgId: null
      }
    },
    methods: {
      reset() {
        this.searchParam = {}
      },
      query() {
        this.$emit('query', this.searchParam)
      }
    },
    watch:{
      searchParam(val){
        this.$emit('change',val)
      }
    }
  }
</script>

<style>
  .input-with-select {
    float: left;
    border-radius: 30px;
  }

  .input-with-select .el-input__inner {
    border-radius: 30px;
  }
</style>
